<template>
  <div class="myOrder" style="background: #f5f5f5;position:relative;width: 100vw;height: 100vh;">
    <van-tabs v-model="active" swipeable @click="tabs(active)"  :sticky='true'>
      <van-tab title="全部">
        <orderList :data="data" class="" :allCount="allCount" :isNone="isNone" @reload="reload"></orderList>
      </van-tab>
      <van-tab title="待付款">
        <orderList :data="data" class="" :allCount="allCount" :isNone="isNone" @reload="reload"></orderList>
      </van-tab>
      <van-tab title="待发货">
        <orderList :data="data" class="" :allCount="allCount" :isNone="isNone" @reload="reload"></orderList>
      </van-tab>
      <van-tab title="待收货">
        <orderList :data="data" class="" :allCount="allCount" :isNone="isNone" @reload="reload"></orderList>
      </van-tab>
      <van-tab title="待评价">
        <commentList></commentList>
      </van-tab>
    </van-tabs>
  </div>
</template>

<script>
  import request from '../request/index'
  import orderList from '../components/order/orderList'
  import commentList from '../components/order/commentList.vue'
    export default {
        name: "myOrder",
      components:{
        orderList,
        commentList
      },
      data(){
          return{
            active:this.$route.query.active,
            status:0,
            page:1,
            data:[],
            allCount:'',
            commentList:[],
            commentCount:'',
            isNone: false,
          }
      },
      methods:{
        tabs(active){
          this.$router.push({
            path:'myOrder',query:{active:active}
          })
        },
        reload(){
          request.getOrder(this,this.active);
        },
        goBack(){
          this.$router.replace({path: '/my'});
        }
      },
      watch:{
        active(newVal,oldVal){
          if (newVal == 0){
            this.status = 0
            request.getOrder(this,this.active);
          } else if(newVal == 1){
            this.status = 1
            request.getOrder(this,this.active);
          }else if(newVal == 2){
            this.status = 2
            request.getOrder(this,this.active);
          }else if(newVal == 3){
            this.status =3
            request.getOrder(this,this.active);
          }else if (newVal == 4){
            this.status =4
            // request.orderComment(this);
          }
        }
      },
      created(){
      },
      mounted(){
          document.title="我的订单";
        if (window.history && window.history.pushState) {
          history.pushState(null, null, document.URL);
          window.addEventListener('popstate', this.goBack, false);
        }
      },
      destroyed(){
        window.removeEventListener('popstate', this.goBack, false);
      },
    }
</script>

<style scoped lang="scss">
.van-hairline--top-bottom{
  position:fixed;
  top:0px;
}
.contents{
  width: 100vw;
  height: auto;
  background: #fff;
  padding-top: 4vw;
  border-bottom: 4vw solid #f5f5f5;
  .ifBlank{
    width: 35vw;
    height:90vh;
    margin: 0px auto;
      img{
        width: 15vw;
        margin: 0px auto;
        margin-left: 10vw;
      }
    p{
      width: 100%;
      color: #666;
      text-align: center;
    }
  }
  .btn{
    float: right;
    .nOrder{
      border: 1px solid #666;
      color: #666;
    }
    .pay{
      border: 1px solid #ff4c50;
      color: #ff4c50;
    }
    button{
      width:18.67vw;
      height: 8vw;
      line-height: 8vw;
      text-align: center;
      background: #fff;
      border-radius: 4vw;
      margin-right: 4vw;
      margin-top: 3.3vw;
    }
  }
  .sec{
    width: 100vw;
    height:26vw;
    line-height:6.67vw;
    border-bottom: 1px solid #f5f5f5;
    .text{
      float: right;
      padding-top: 3vw;
      width: 73vw;
      .seven{
        width: 32vw;
        height: 4.34vw;
        color: #ff4c50;
        border: 1px solid #ff4c50;
        border-radius: 4vw;
        line-height: 4vw;
        text-align: center;
        margin-top: 4vw;
        font-size: 11px;
      }
      p{
        height: 5vw;
        .types{
          float: right;
          color: #FF4C50;
          font-size: 13px;
          margin-right: 4vw;
        }
      }
      .size{
        font-size: 12px;
        color: #666;
      }
      .name{
        font-size: 13px;
        color: #333;

        .goodsName{
          width: 41vw;
          text-overflow: ellipsis;
          white-space: nowrap;
          overflow: hidden;
          display: inline-block;
        }
      }
    }
    img{
      width: 20vw;
      height: 20vw;
      float: left;
      margin-left: 4vw;
      margin-top: 2.67vw;
      border-radius: 3px;
    }
  }

}
</style>
<style lang="scss">
  .myOrder{
  .van-tabs--line .van-tabs__wrap{
    height: 11vw;
  }
  .van-tabs__content{
    margin-top: 7vw !important;
  }
  .van-tab--active div, .van-tab--active span{
    color: #FF4C50 !important;
  }
  }

</style>
